package org.zy.thread;

import org.zy.model.Test;

/**
 * @author Zhang Yu
 * @description: TODO
 * @date 2024/4/24 16:17
 */
public class RunnableDemo implements Runnable{
    private Thread t;
    private String threadName;
    private static Test test = new Test();

    public RunnableDemo(String threadName) {
        this.threadName = threadName;
    }

    @Override
    public void run() {
        System.out.println("Running  = " + threadName);
        for (int i = 0; i < 100000; i++) {
            test.add();
        }
        System.out.println("Thread " +  threadName + " exiting.");
    }
    
    public void start(){
        System.out.println("Starting  = " + threadName);
        if (t == null) {
            t = new Thread(this, threadName);
            t.start();
        }
    }
}
